<template>
  <a-card :bordered="false">
    <div class="table-page-search-wrapper">
      <a-form layout="inline"  @keyup.enter.native="searchQuery">
        <a-row :gutter="12">
          <a-col :md="4" :sm="8">
            <a-form-item label="" :labelCol="{ span: 6 }" :wrapperCol="{ span: 14, offset: 0 }">
              <a-input placeholder="订单编号" v-model="queryParam.orderNo"></a-input>
            </a-form-item>
          </a-col>

          <a-col :md="4" :sm="8">
            <a-form-item label="" :labelCol="{ span: 6 }" :wrapperCol="{ span: 14, offset: 1 }">
              <a-input placeholder="活动名称" v-model="queryParam.name"></a-input>
            </a-form-item>
          </a-col>

          <a-col :md="4" :sm="8">
            <a-form-item label="" :labelCol="{span: 6}" :wrapperCol="{span: 14, offset: 1}">
              <a-select v-model="queryParam.orderType" placeholder="状态" allowClear default-value="null" :getPopupContainer="triggerNode => triggerNode.parentNode">
                <a-select-option value="1">待核销</a-select-option>
                <a-select-option value="2">已核销</a-select-option>
                <a-select-option value="3">已过期</a-select-option>
                <a-select-option value="4">已取消</a-select-option>
              </a-select>
            </a-form-item>
          </a-col>

          <a-col :md="4" :sm="8">
            <a-form-item label="" :labelCol="{span: 6}" :wrapperCol="{span: 14, offset: 1}">
              <a-range-picker @change="onChange" v-model="data" />
            </a-form-item>
          </a-col>
          
          <a-col :md="4" :sm="8">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
            </span>
          </a-col>
        </a-row>
      </a-form>

      <a-table
        ref="table"
        rowKey="id"
        size="middle"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        @change="handleTableChange">
        <span slot="action" slot-scope="text, record">
          <a @click="detailEdit(record)">
            <a-icon type="edit"/>
            详情
          </a>
        </span>
      </a-table>
    </div>

    <order-Modal ref="modalForm" @ok="modalFormOk"></order-Modal> 
  </a-card>
</template>

<script>
import { filterObj } from '@/utils/util';
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import orderModal from './modules/orderModal'

export default {
  name:'order',
  mixins:[JeecgListMixin],
  components: { 
    orderModal
  },
  data() {
    return {
      queryParam:{
        current: 1,
        size: 10,
      },
      data:[],
      // 表头
      columns: [
        {
          title: '序号',
          dataIndex: '',
          key: 'rowIndex',
          width: 120,
          align: "center",
          customRender: function (t, r, index) {
            return parseInt(index) + 1;
          }
        },
        {
          title: '订单编号',
          align: "center",
          dataIndex: 'orderNo',
        },
        {
          title: '活动名称',
          align: 'center',
          dataIndex: 'activityName',
        },
        {
          title: '价格积分',
          align: 'center',
          dataIndex: 'price',
        },
        {
          title: '状态',
          align: 'center',
          dataIndex: 'orderStatus',
          // scopedSlots: { customRender: 'orderType' }
        },
        {
          title: '预约信息',
          align: 'center',
          dataIndex: 'details',
        },
        {
          title: '下单时间',
          align: 'center',
          dataIndex: 'createTime',
        },
        {
          title: '操作',
          align: "center",
          dataIndex: 'action',
          scopedSlots: {customRender: 'action'},
        }
      ],
      url: {
        list: "/backend/invitation/pageOrderVo",
      },
    }
  },
  created() {
  },
  methods: {
    getQueryParams() {
      var param = Object.assign({}, this.queryParam);
      param.current = this.ipagination.current;
      param.size = this.ipagination.pageSize;
      return filterObj(param);
    },
    searchReset() {
      this.data = []
      this.queryParam = {}
      this.loadData(1);
    },
    onChange(date, dateString) {
      this.queryParam.startTime = dateString[0]
      this.queryParam.endTime = dateString[1]
    },
    detailEdit(record) {
      console.log('1');
      this.$refs.modalForm.edit(record);
      this.$refs.modalForm.title = "详情";
      this.$refs.modalForm.disableSubmit = false;
    },
  }
}
</script>
<style scoped>
  @import '~@assets/less/common.less'
</style>